package com.shf.lease.exception;

import com.shf.lease.result.BaseErrorInfoInterface;

/**
 * @author 叶枫
 * @date 2024/7/5.
 */


public class BizException extends RuntimeException{

    private static final long serialVersionUID = 1L;
    protected Integer errorCode;
    protected String errorMsg;

    public BizException() {
        super();
    }
    public BizException(BaseErrorInfoInterface baseErrorInfoInterface) {
        super(baseErrorInfoInterface.getCode().toString());
        this.errorCode = baseErrorInfoInterface.getCode();
        this.errorMsg = baseErrorInfoInterface.getMessage();
    }

    public BizException(String errorMsg) {
        super(errorMsg);
        this.errorMsg = errorMsg;
    }
    public BizException(Integer errorCode, String errorMsg) {
        super(String.valueOf(errorCode));
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }
    public BizException(Integer errorCode, String errorMsg, Throwable cause) {
        super(String.valueOf(errorCode), cause);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }
    public BizException(BaseErrorInfoInterface errorInfoInterface, Throwable cause) {
        super(errorInfoInterface.getCode().toString(), cause);
        this.errorCode = errorInfoInterface.getCode();
        this.errorMsg = errorInfoInterface.getMessage();
    }
    public Integer getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(Integer errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }


}
